package com.dongwu.manager.service.impl;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dongwu.common.service.impl.BaseServiceImpl;
import com.dongwu.common.utils.UserUtils;
import com.dongwu.manager.dao.CultureDao;
import com.dongwu.manager.entity.Culture;
import com.dongwu.manager.service.CultureService;
import com.dongwu.security.service.IUserService;

@Service
public class CultureServiceImpl extends BaseServiceImpl<Culture, String> implements CultureService {
	@Autowired
	private CultureDao cultureDao;
	@Autowired
	private IUserService userService;
	@Override
	public List<Culture> findCulture(String device_id, Integer titleType,Integer pageNo,Integer pageSize) {
		// TODO Auto-generated method stub
		return cultureDao.findCulture(device_id, titleType,pageNo,pageSize);
	}
	@Override
	public Culture save(Culture entity) {
		/*关联当前用户*/
		if (entity.getUser() == null) {
			entity.setUser(userService.findByLoginName(UserUtils.getUserLoginName()));
		}
		return super.save(entity);
	}
	@Override
	public List<Culture> findCulture(String device_id, Integer titleType) {
		// TODO Auto-generated method stub
		return cultureDao.findCulture(device_id, titleType);
	}
	
}
